<template>
    <div class="mui-numbox" data-numbox-min='1' style="height:25px">
        <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
        <input class="mui-numbox-input" type="number" :value="initcount" ref="nobox" @change="countChanged"/>
        <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
</template>

<script>
// 导入mui从而支持初始化数字框
import mui from '../../../lib/mui/js/mui.js'
import {mapMutations} from 'vuex'
export default {
    data(){
        return{}
    },
    methods:{
        countChanged() {
      // 获取选择的商品数量
        const val = parseInt(this.$refs.nobox.value);
        this.updateGoodsCount({id:this.id,count:val})

    },
    ...mapMutations(["updateGoodsCount"])

    },
    mounted(){
        mui(".mui-numbox").numbox()
    },
    props:["initcount","id"]


}
</script>

<style lang="scss" scoped>

</style>